package com.furkid.service.controller;

import com.furkid.service.constant.AjaxResult;
import com.furkid.service.domain.pet.PetDisease;
import com.furkid.service.service.IHealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/health")
public class HealthController {
    @Autowired
    IHealthService iHealthService;

    /**
     * 获取健康信息列表
     * @param id 宠物id
     * @return 返回宠物健康信息列表
     */
    @GetMapping("/disease/list/{id}")
    public AjaxResult petDiseaseListByPetId(@PathVariable Long id) {
        return AjaxResult.success("获取宠物健康信息列表成功!!!", iHealthService.petDiseaseListByPetId(id));
    }

    /**
     * 添加宠物病情
     * @param petDisease 宠物病情信息
     * @return 返回操作结果
     */
    @PostMapping("/disease/add")
    public AjaxResult addPetDisease(@RequestBody PetDisease petDisease) {
        iHealthService.addPetDisease(petDisease);
        return AjaxResult.success("添加宠物病情成功!!!");
    }

    /**
     * 更新宠物病情
     * @param petDisease 宠物病情信息
     * @return 返回操作结果
     */
    @PutMapping("/disease/update")
    public AjaxResult updatePetDisease(@RequestBody PetDisease petDisease) {
        iHealthService.updatePetDisease(petDisease);
        return AjaxResult.success("更新宠物病情成功!!!");
    }

    @DeleteMapping("/disease/delete/{id}")
    public AjaxResult deletePetDisease(@PathVariable Long id, @RequestParam Long petId) {
        iHealthService.deletePetDisease(id, petId);
        return AjaxResult.success("删除宠物病情成功!!!");
    }
}
